// 定义一个学生类型, 使用类型关键字 type
type Student = {
  name: string;
  gender: string;
  score: number;
  height: number;
  study: () => void;
  code: (code: string) => string;
};

// 使用接口定义类型
interface IPerson {
  name: string;
  age: number;
  sayHi: () => void;
}

// 使用接口定义一个对象
let person: IPerson = {
  name: 'Jack',
  age: 18,
  sayHi: (): void => {
    console.log('hello');
  },
};

console.log(person.name, person.sayHi());

// 接口的继承，定义一个学生接口，继承 IPerson 接口
interface IStudent extends IPerson {
  // 学生有额外的属性
  score: number;
  study: () => string;
}

let stu: IStudent = {
  score: 100,
  study: () => {
    return 'good good study';
  },
  name: 'Jack',
  age: 18,
  sayHi: () => {
    console.log('hello');
  },
};

console.log(stu.study());

export {};
